﻿/*
*   Select category
*/
function selectCategorie()
{
	$('.categories').children('div.selected').removeClass('selected');
	$(this).addClass('selected');
	var selectedCat = $(this).attr('id');
	$('#sortable1').children('li').each(function ()
	{
		if ($(this).attr('categorie') === selectedCat)
		{
			$(this).show();
		} else { $(this).hide(); }
	});
	if ($('ul#sortable2').height() < $('ul#sortable1').height())
	{
		$('ul#sortable2').height($('ul#sortable1').height());
	}
	else
	{
		$('ul#sortable2').removeAttr('style');
	}
}

$(function ()
{
	$('#validateApplication').click(function ()
	{
		var s = 0;
		validateApplications();
	});

	$('.grab').bind('mouseover', function ()
	{
		var desc = $(this).attr('description');
		$(this).append("<div class='info' style='position:absolute;top:0'>" + desc + "</div>");
	});
	$('.grab').bind('mouseout', function ()
	{
		$(this).children('div.info').remove();
	});

	/**
	*
	* On Direction Selection change
	*/
	$('select#direction-filter').on('change', function ()
	{
		var selecteddirection = $(this).find(':selected').text();
		if (selecteddirection != "Choisir une direction..." && selecteddirection != "AUTRES")
		{
			var dataParameters = { search: 'application', filterType: 'directionRecursive', filterValue: selecteddirection };
			callApplicationPageSelectedApps(dataParameters, setAvailableApplications);
		}
		else
		{
			if (selecteddirection == "AUTRES")
			{
				getAvailableApplications();
			}
		}
	});
});